/* ----------------------------------------------------------------------------------------------------------------
 * SoundItem
 * ----------------------------------------------------------------------------------------------------------------
 */
package pure.sound
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundTransform;
	import flash.net.URLLoader;
	import flash.net.URLRequest;


internal class SoundItem
{
	public function SoundItem()
	{
		this._url = url;
		this._sound = new Sound();
		this._soundTransform=new SoundTransform();
		this._sound.addEventListener(IOErrorEvent.IO_ERROR,____onIoError);
	}
	
	protected var _url						:String;						/*文件地址*/
	protected var _isPlaying				:Boolean;					/*是否正在播放*/
	protected var _sound:Sound;					/*声音*/
	protected var _soundChannel:SoundChannel;
	protected var _soundTransform:SoundTransform;			/*音质*/

	protected var _isPreload				:Boolean;
	protected var _isLoaded				:Boolean;
	
	// ----------------------------------［ Cache ］----------------------------------
	
	protected var _request:URLRequest;
	
	
	/*调节音量*/
	public function set volume(value:Number):void
	{
		if(this._soundTransform.volume==value){
			return;
		}
		this._soundTransform.volume=value;
	}
	
	public function get volume():Number
	{
		return this._soundTransform.volume;
	}
	
	/*<only-read>声音总长度*/
	public function get length():Number
	{
		return _sound.length;
	}
	
	/*<only-read>是否正在播放*/
	public function get isPlaying() : Boolean
	{
		return this._isPlaying;
	}
	
	/*<only-read>文件地址*/
	public function get url() : String
	{
		return this._url;
	}
	
	public function get sound():Sound
	{
		return this._sound;
	}
	
	
	
	
	protected function ____onIoError(e:IOErrorEvent):void
	{
		this._sound.removeEventListener(IOErrorEvent.IO_ERROR ,____onIoError);
		trace("<CSound::URL::"+this._url+">加载操作失败!");
	}

}
}